package pattern.behavioral.Interpreter.simple;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: chaoyang.ren  
 * @date:Jun 22, 2017  
 * @time:4:22:11 PM   
 * @email:chaoyang.ren@foxmail.com  
 * @version: 1.0
 */
public class Context {
	private Map<Variable,Boolean> map = new HashMap<Variable,Boolean>();
	    
    public void assign(Variable var , boolean value){
        map.put(var, new Boolean(value));
    }
    
    public boolean lookup(Variable var) throws IllegalArgumentException{
        Boolean value = map.get(var);
        if(value == null){
            throw new IllegalArgumentException();
        }
        return value.booleanValue();
    }
}

